﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using MVCSayDemo.Models;

namespace MVCSayDemo.Data
{
    public class MVCSayDemoDbInit:DropCreateDatabaseAlways<MsgContext>
    {
        protected override void Seed(MsgContext db)
        {
            db.Users.AddRange(new List<Users>
            {
                new Users
                {
                    Username="ruan",
                    Password="123",
                    CreateAt = DateTime.Now,
                    UpdateAt = DateTime.Now,
                    Version = 0
                },
                new Users
                {
                    Username="yang",
                    Password="123",
                    CreateAt = DateTime.Now,
                    UpdateAt = DateTime.Now,
                    Version = 0
                },
                new Users
                {
                    Username="jing",
                    Password="123",
                    CreateAt = DateTime.Now,
                    UpdateAt = DateTime.Now,
                    Version = 0
                }
            });
            db.Messages.AddRange(new List<Messages>
            {
                new Messages
                {
                    FromUserId=1,
                    Content="太阳",
                    CreateAt = DateTime.Now,
                    UpdateAt = DateTime.Now,
                    Version = 0
                },
                 new Messages
                {
                    FromUserId=2,
                    Content="月亮",
                    CreateAt = DateTime.Now,
                    UpdateAt = DateTime.Now,
                    Version = 0
                },
                  new Messages
                {
                    FromUserId=1,
                    Content="星星",
                    CreateAt = DateTime.Now,
                    UpdateAt = DateTime.Now,
                    Version = 0
                }
            });
            db.Comments.AddRange(new List<Comments>
            {
                new Comments
                {
                    FromUserId=1,
                    MsgId=1,
                    Content="☀",
                    CreateAt = DateTime.Now,
                    UpdateAt = DateTime.Now,
                    Version = 0
                },
                new Comments
                {
                    FromUserId=2,
                    MsgId=2,
                    Content="🌙",
                    CreateAt = DateTime.Now,
                    UpdateAt = DateTime.Now,
                    Version = 0
                },
                new Comments
                {
                    FromUserId=1,
                    MsgId=2,
                    Content="清风明月",
                    CreateAt = DateTime.Now,
                    UpdateAt = DateTime.Now,
                    Version = 0
                }
            });
            db.SaveChanges();
            base.Seed(db);
        }
    }
}